package handler

import (
	"api/basic/global"
	__ "api/basic/proto"
	"api/internal/params"
	"github.com/gin-gonic/gin"
	"net/http"
)

func VideoList(c *gin.Context) {
	var req params.VideoListReq

	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}

	list, err := global.VideoClient.VideoList(c, &__.VideoListReq{
		Page:     int32(req.Page),
		Size:     int32(req.Size),
		Types:    req.Types,
		Category: req.Category,
		Area:     req.Area,
	})

	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}

	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "展示成功",
		"data": list,
	})

}
